
local models = {
    [[TX_ssdf_1.mdl]],
    [[TX_ssdf_2.mdl]],
    [[TX_ssdf_3.mdl]],
}
ac.skill('三色刀法'){
    temp = '攻击触发',
    on_run = function(self,hero,target)
        --hero:add_buff '三色刀法-效果'{}
        local point1 = hero:get_point()
        local point2 = target:get_point()
        local angle = point1 / point2
        local index = 0
        ac.timer(200,3,function()
            index = index + 1
            local model = models[index]
            local mover = hero:launch_wave(model,angle,1200,900)
            local damage = self:dmg_get()
            mover:set_height(100)
            sc.loopUnit(0.03,mover,120,function(group,unit)
                if unit:is_enemy(hero) then
                    hero:create_damage(unit,damage,self)
                end
            end)
        end)
    end,
}


local buff = ac.buff['三色刀法-效果']
buff.max_count = 3
buff.count = 0
buff.model1 = [[TX_ssdf_1.mdl]]
buff.model2 = [[TX_ssdf_2.mdl]]
buff.model3 = [[TX_ssdf_3.mdl]]
function buff:on_add()
    local hero = self.owner
    local models = {self.model1,self.model2,self.model3}
    self:gc(hero:event '单位-攻击命中'(function(_,_,target)
        local point1 = hero:get_point()
        local point2 = target:get_point()
        local angle = point1 / point2
        local model = models[self.count%3 + 1]
        local mover = hero:launch_wave(model,angle,1200,900)
        local damage = self:dmg_get()
        mover:set_height(100)
        sc.loopUnit(0.03,mover,120,function(group,unit)
            if unit:is_enemy(hero) then
                hero:create_damage(unit,damage,self)
            end
        end)
        self.count = self.count + 1
        if self.count>=self.max_count then
            self:remove()
        end
    end))
end

function buff:on_cover(new)
    self.max_count = self.max_count + 3
    return false
end